package com.trkj.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.DeptDAO;
import com.trkj.dao.EmpDAO;
import com.trkj.pojo.Dept;
import com.trkj.pojo.Emp;
import com.trkj.vo.ReloanVo;

@Service
@Transactional
public class ReloanService {
	
	@Autowired
	EmpDAO empDao;
	@Autowired
	DeptDAO deptDAO;
	/**
	 * 还款时查询用户基本信息
	 * @param empId
	 * @return
	 */
	public ReloanVo getReloanEmpInfo(Integer empId) {
		Emp emp = empDao.findOne(empId);
		ReloanVo reloanVo = new ReloanVo();
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		if (emp!=null) {
			reloanVo.setEmpId(emp.getEmpId()+"");
			reloanVo.setEmpName(emp.getEmpName());
			Dept dept = emp.getDept();
			if (dept!=null) {
				reloanVo.setDeptId(dept.getDeptId()+"");
				reloanVo.setDeptName(dept.getDeptName());
			}
			reloanVo.setLunchPeople(empId);
			reloanVo.setEmpLoanbalance(emp.getEmpLoanbalance()+"");
			reloanVo.setReloanUptime(new Date());
		}
		return reloanVo;
	}
}
